/**
 * 
 */
package com.lehecai.core.api.event;

import com.lehecai.core.YesNoStatus;
import com.lehecai.core.api.AbstractApiResultBean;
import com.lehecai.core.util.CoreDateUtils;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

/**
 * 已领取信息
 * @author He Wang
 */
public class EventUserQualify extends AbstractApiResultBean {

	public static final String QUERY_UID = "uid";
	public static final String QUERY_EVENT_ID = "event_id";
	public static final String QUERY_TIMELINE="timeline";

	private Integer eventId;	//活动编码
	private Long uid;
	private String userName;
	private String eventName;//开放时间段
	private Date eventTimeStart;
	private Date eventTimeEnd;
	private String sourceId;

	private Date timeline;          //领取时间

	public static EventUserQualify convertFromJSONObject(JSONObject object) {
		if (object == null) {
			return null;
		}
		EventUserQualify eventUserQualify = new EventUserQualify();
		eventUserQualify.eventId = getInt(object, "event_id");
		eventUserQualify.uid = getLong(object, "uid");
		eventUserQualify.eventName = getString(object, "event_name");
		eventUserQualify.eventTimeStart = CoreDateUtils.parseDate(getString(object, "event_time_start"), CoreDateUtils.DATETIME);
		eventUserQualify.eventTimeEnd = CoreDateUtils.parseDate(getString(object, "event_time_end"), CoreDateUtils.DATETIME);
		eventUserQualify.timeline = CoreDateUtils.parseDate(getString(object, "timeline"), CoreDateUtils.DATETIME);
		eventUserQualify.userName = getString(object, "username");
		eventUserQualify.sourceId = getString(object, "source");
		return eventUserQualify;
	}
	
	public static List<EventUserQualify> convertFromJSONArray(JSONArray array) {
		if (array == null) {
			return null;
		}
		List<EventUserQualify> list = new ArrayList<EventUserQualify>();
		for (Iterator<?> iterator = array.iterator(); iterator.hasNext();) {
			JSONObject object = (JSONObject) iterator.next();
			list.add(convertFromJSONObject(object));
		}
		return list;
	}

	public Integer getEventId() {
		return eventId;
	}

	public void setEventId(Integer eventId) {
		this.eventId = eventId;
	}

	public Long getUid() {
		return uid;
	}

	public void setUid(Long uid) {
		this.uid = uid;
	}

	public Date getEventTimeEnd() {
		return eventTimeEnd;
	}

	public void setEventTimeEnd(Date eventTimeEnd) {
		this.eventTimeEnd = eventTimeEnd;
	}

	public Date getEventTimeStart() {
		return eventTimeStart;
	}

	public void setEventTimeStart(Date eventTimeStart) {
		this.eventTimeStart = eventTimeStart;
	}

	public String getEventName() {
		return eventName;
	}

	public void setEventName(String eventName) {
		this.eventName = eventName;
	}

	public Date getTimeline() {
		return timeline;
	}

	public void setTimeline(Date timeline) {
		this.timeline = timeline;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getSourceId() {
		return sourceId;
	}

	public void setSourceId(String sourceId) {
		this.sourceId = sourceId;
	}
}
